<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">房间编号：</label>
            <div class="layui-input-inline seller-inline-3">
                <input type="text"  name="room_bn" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">商品名称：</label>
            <div class="layui-input-inline seller-inline-3">
                <input type="text"  name="goods_name" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="goods-search"><i class="iconfont icon-chaxun"></i>筛选</button>
            </div>
        </div>
    </div>
</form>

<div class="table-body">
    <table id="stockTable" lay-filter="stockTable"> </table>
</div>
<script>
    layui.use(['laydate', 'table', 'layer', 'form'], function () {
        var laydate = layui.laydate;
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form
        //执行一个laydate实例
        var run = table.render({
            elem: '#stockTable',
            url: "{:url('stockList')}?_ajax=1",
            cols: [[
                { field: 'id', minWidth: 120, title: 'ID', align: 'center' },
                { field: 'room_bn', minWidth: 120, title: '房间编号', align: 'center' },
                { field: 'goods_name', minWidth: 150, title: '商品名称', align: 'center'},
                { field: 'type', minWidth: 100, title: '类型', align: 'center', templet:function(data){
                    if(data.type == 1) {
                        return '出库';
                    } else {
                        return '入库';
                    }
                }},
                { field: 'quantity', minWidth: 100, title: '数量', align: 'center'},
                { field: 'memo', minWidth: 150, title: '备注', align: 'center' },
                { field: 'date', minWidth: 150, title: '操作时间', align: 'center' },
            ]],
            page:true
        });
        form.on('submit(goods-search)', function(data){
            var tempfilter=data.field//合并tab筛选和普通搜索
            run.reload({
                where: tempfilter
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>